using Firestarter.Test.Base;
using Habanero.BO;
using NUnit.Framework;

namespace FireStarterModeller.Test
{
    /// <summary>
    /// Provides a parent class that test classes can inherit from and use to
    /// initialise the testing environment.
    /// This class is only written once, so you can safely modify it.
    /// </summary>
    public class TestBase
    {
        //-------------------------------------------------------------------------------------
        //
        // Set the connection details for your database here.
        // Then add the necessary DLL for that database to the references in this test project.
        //
        //        *** CAUTION! ***
        //
        // The database tables are cleaned before tests are executed.  Do not run the tests
        // against a live database unless you are able to restore the data afterwards.  Rather
        // copy the live database and run the tests on the copy.
        //
        //-------------------------------------------------------------------------------------
//        protected DatabaseConfig _databaseConfig = new DatabaseConfig
//            ("mysql", "localhost", "mydatabase", "root", "root", "3306");

/*        public TestBase()
        {
            //if (DatabaseConnection.CurrentConnection == null)
            //{
            //    DatabaseConnection.CurrentConnection = _databaseConfig.GetDatabaseConnection();
            //}
        }*/

        [TestFixtureSetUp]
        public void SetupFixture()
        {
            TestUtilsDomain.SetupFixture();
        }

        [SetUp]
        public virtual void SetupTest()
        {
            //-------------------------------------------------------------------------------------
            // You can choose here whether to run against a database or whether to use an in-memory
            // database for all the tests, which runs quickly. It doesn't however check that
            // your database has the correct structure, which is partly the purpose of these tests.
            // The generated tests do already use an in-memory database where possible.
            // In your custom tests, you can set them to use an in-memory database by copying the
            // line to the first line of your test.
            //-------------------------------------------------------------------------------------
            //BORegistry.DataAccessor = new DataAccessorDB();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            TestUtilsDomain.SetupTest();
        }

        [TearDown]
        public virtual void TearDownTest()
        {
        }
    }
}